﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_GetOperationFileTip]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_GetOperationFileTip];
GO
CREATE PROCEDURE [dbo].[sproc_GetOperationFileTip]
    @DocID int,
    @ToID int,
    @OperationType int
/*

============================================================
功能:    得到文件操作提示
参数:
    @DocID int        :    :    文档的ID
    @ToID int            :    目标组的ID
    @OperationType in        :    操作类型
备注:    在文件复制，转移后的提示

============================================================

*/
AS
DECLARE @tip nvarchar(2000)
DECLARE @FromName nvarchar(1000)
DECLARE @ToName nvarchar(1000)
--得到源文档的组名
SELECT @FromName = classname 
    FROM uds_class
    WHERE classid = (select classid from uds_document WHERE docid = @DocID)
--得到目标组的组名
SELECT @ToName = classname 
    FROM uds_class
    WHERE classid = @ToID
IF @OperationType =0
    SET @tip = '从[' + @FromName + ']复制到[' + @ToName + ']成功!'
IF @OperationType =1
    SET @tip = '从[' + @FromName + ']转移到[' + @ToName + ']成功!'
IF @OperationType =2
BEGIN
    SELECT @ToName = classname 
        FROM uds_class
        WHERE classid = (select classparentid where classid = (select classid from uds_document WHERE docid = @DocID))    
    SET @tip = '从[' + @FromName + ']呈送到[' + @ToName + ']成功!'
END

SELECT @tip